class_name BallStateShot
extends BallState

#球在天上飞的时间
const DURATION_SHOT := 1000
#球在天上飞的默认高度
const SHOT_HEIGHT := 5

#球被踢了，在天上飞产生的型变
const SHOT_SPRITE_SCALE := 0.8

var time_since_shot := Time.get_ticks_msec()

func _enter_tree() -> void:
	sprite.scale.y = SHOT_SPRITE_SCALE
	ball.height = SHOT_HEIGHT
	time_since_shot = Time.get_ticks_msec()
	GameEvents.impact_received.emit(ball.position,true)
	shot_particles.emitting = true

func _process(delta: float) -> void:
	set_ball_animation_from_velocity()
	
	if Time.get_ticks_msec() - time_since_shot > DURATION_SHOT:
		transtition_state(Ball.State.FREEFORM)
	else:
		move_and_bounce(delta)



func _exit_tree() -> void:
	sprite.scale.y = 1.0
	shot_particles.emitting = false
